{include file="common@public/_category" /}

  <!--container-->
  <div class="container container-gary">
      <!-- page banner -->
      <div class="page-banner" style="background:url(/public/uploads/timages/page-banner1.jpg) no-repeat center top"></div>
      <div class="container-ptb wrap">
          <div class="selector-con">
              <div class="selector-list clearfix">
                  <div class="selector-head">类别：</div>
                  <div class="selector-value">
                      <ul class="selector-v-list clearfix">
                        {foreach name='category_list' item='vo'}
                          <li data-id='class_{$vo.typeid}' {if condition="$id eq $vo.typeid"} class="selected" {/if}><a>{$vo.classname}<i class="select-i"></i></a></li>
                        {/foreach}
                      </ul>
                      <div class="selector-more"><span>+多选</span></div>
                      <div class="selector-btn"><a class="submit-a">确定</a><a class="cancel-a">取消</a></div>
                  </div>
              </div>
              <div class="selector-list clearfix">
                  <div class="selector-head">品牌：</div>
                  <div class="selector-value">
                      <ul class="selector-v-list clearfix">
                        {foreach name='brand_list' item='vo'}
                          <li data-id='brand_{$vo.brandid}' ><a>{$vo.brandname}<i></i></a></li>
                        {/foreach}
                      </ul>
                      <div class="selector-more"><span>+多选</span></div>
                      <div class="selector-btn"><a class="submit-a">确定</a><a class="cancel-a">取消</a></div>
                  </div>
              </div>
              <div class="selector-list clearfix">
                  <div class="selector-head">色系：</div>
                  <div class="selector-value">
                      <ul class="selector-color clearfix">
                        {foreach name='colorgroup_list' item='vo' }
                          {notempty name="vo.colorgroupvalue2"}
                          <li data-id="color_{$vo.colorgroupid}"><a><spa class="coler-grid" style="background-color:#{$vo.colorgroupvalue1};"><span class="color-cell" style="background-color:#{$vo.colorgroupvalue2};"></span></spa>{$vo.groupname}</a></li>
                          {else/}
                          <li data-id="color_{$vo.colorgroupid}"><a><span class="coler-grid" style="background-color:#{$vo.colorgroupvalue1};"></span>{$vo.groupname}</a></li>
                          {/notempty}
  
                        {/foreach}
                        
                      </ul>
                      <div class="selector-more"><span>+多选</span></div>
                      <div class="selector-btn"><a class="submit-a">确定</a><a class="cancel-a">取消</a></div>
                  </div>
              </div>
              {foreach name='attr_list' item='vo'}
              <div class="selector-list clearfix">
                  <div class="selector-head">{$vo.attrname}：</div>
                  <div class="selector-value">
                      <ul class="selector-v-list clearfix">
                        {foreach name='vo.list' item='co'}
                          <li data-id="attr_{$vo.attrid}_{$co}"><a>{$co}<i></i></a></li>
                        {/foreach}
                      </ul>
                      <div class="selector-more"><span>+多选</span></div>
                      <div class="selector-btn"><a class="submit-a">确定</a><a class="cancel-a">取消</a></div>
                  </div>
              </div>
              {/foreach}
          </div>
          
          <div class="selected-name clearfix">
              <div class="selected-n-total">全部></div>
              <ul class="selected-n-ul">
              </ul>
          </div>
          <div id='screen'>

          </div>
      </div>

  </div>

<script type="text/javascript" src="/public/static/home/js/menu.js"></script>
<script>
    var page = 'page_1';
    $(function(){
      //top select
      //直接调用查询
      
      search();

      $(".top-select").mouseover(function () {
        $(".top-s-text").show();
      })
      $(".top-select").mouseout(function () {
        $(".top-s-text").hide();
      })
      $(".top-s-text div").click(function () {
        var selecttext = $(this).text();
        $(".top-s-head span").text(selecttext);
        $(this).parent(".top-s-text").hide()
      })
      // top code
      var turn = function(target,time,opts){
      target.find('.top-code').hover(function () {
            $(this).find('.top-c-img').stop().animate(opts[0], time, function () {
      $(this).hide().next().show();
      $(this).next().animate(opts[1],time);
     });
     },function(){
          $(this).find('.top-c-text').animate(opts[0], time, function () {
          $(this).hide().prev().show();
          $(this).prev().animate(opts[1],time);
     });
       });
        }
        var verticalOpts = [{'width':0},{'width':'80px'}];
        turn($('.top-right'), 150, verticalOpts);
        //menu all
        $(".menu-all div").mouseenter(function () {
            $(this).addClass("current");
            $(".submenu").show();
        })
       $(".menu-all div").mouseleave(function () {
            $(this).removeClass("current");
            $(".submenu").hide();
        })
        $(".submenu").mouseenter(function(){
           $(this).show();
           $(".menu-all div").addClass("current")
        })
        $(".submenu").mouseleave(function(){
           $(this).hide();
           $(".menu-all div").removeClass("current")
        })

        //left submenu
        $(".submenu ul li").each(function () {
            var $this = $(this);
            var $children = $this.find('.submenu-pro');
            var $otherChildren = $this.siblings('li').find('.submenu-pro');
            var $childrenList = $children.children('.submenu-total');
            $this.on({
                'mouseenter': function () {
                    $children.css({ 'display': 'block', 'width': 221 * parseInt($childrenList.size()) });
                    $otherChildren.css('display', 'none');
                },
                'mouseleave': function () {
                    $children.css('display', 'none');
                }
            })
        });
        //selector-con
        $(".selector-value ul li").bind("click", radio);
            $(".selector-color ul li").bind("click", function () {
                $(this).addClass("current").siblings().removeClass("current")
        })
        $(".selector-more").bind("click", function () {
            $(this).hide();
            $(this).siblings(".selector-btn").show();

            $(this).parent(".selector-value").addClass("va-selected");
            $(this).parent(".selector-value").find("ul li").unbind("click", radio);
            $(this).parents(".va-selected").find("ul li").bind("click", Multiselect);

            $(".va-selected ul li i").bind("click", function () {
                $(this).parents(".selector-value ul li").removeClass("selected");
                return false;
            })
            $(".cancel-a,.submit-a").bind("click", function () {
                $(this).parents(".selector-value").find("ul li").bind("click", radio);
                $(this).parents(".va-selected").find("ul li").unbind("click", Multiselect);
                $(this).parents(".selector-value").removeClass("va-selected");
                $(this).parents(".selector-btn").hide();
                $(this).parents(".selector-btn").siblings(".selector-more").show();
            })
            $(".cancel-a").bind("click", function () {
                $(this).parent(".selector-btn").siblings("ul").children("li").removeClass("selected");
                search();
            })
            var count = $(this).siblings(".va-selected ul").find("li.selected").size();
            if (count >= 1) {
                $(this).siblings(".selector-btn").find(".submit-a").addClass("sub-selected");
            } else {
                $(this).siblings(".selector-btn").find(".submit-a").removeClass("sub-selected");
            }
            $(this).siblings("ul").find("li").bind("click", function () {
                var count_sum = $(this).parent(".selector-value ul").find("li.selected").size();
                if (count_sum >= 1) {
                    $(this).parent(".selector-value ul").siblings(".selector-btn").find(".submit-a").addClass("sub-selected");
                }
            })
        })
        $(".selector-value ul li i").bind("click", function () {

            $(this).parents(".selector-value ul li").removeClass("selected");
            search();
            return false;
        })
        $(".selected-n-ul li i").click(function(){
            $(this).parent("li").hide();
        })
        //sort left
        $(".sort-left span").live('click',function () {
            $(this).addClass("current").siblings().removeClass("current");
            search();
        })
        $('.del_selected').live('click',function(){
        var this_id = $(this).data('id');
        $.each($('.selected'),function(key,value){
          if($(this).data('id') == this_id){
            $(this).removeClass('selected');
          }
        })
        $(this).parent().remove();
        search();
      })

        $('.ajax_screen').live('click', function(){
          var page_href = $(this).attr('href');
          var page_data = page_href.split('?page=');
          page      = 'page_'+page_data[1];
          search();
          return false;
        })
    })
    function search(){
        var newid = "category_{$newid}";
        var keyword     = "keyword_{$keyword}";
        var select_list = $('.selected');
        var all_select  = [];
        var has_select  = '';
        var tag         = '';
        $.each(select_list,function(key,value){
          all_select.push($(this).data('id'));
          has_select += '<li>'+$(this).parent().parent().parent().find('.selector-head').text()+$(this).text()+' <i class="del_selected" data-id="'+$(this).data('id')+'"></i></li>';
        })
        $('.selected-n-ul').html(has_select);
        all_select.push(newid);

        var tag = $('.sort-left .current').data('id');
        all_select.push(tag);
        all_select.push(page);
        all_select.push(keyword);
        page = 'page_1';

         $.ajax({
             type: "post",
             url: "{:url('product/screen')}",
             data: {all_select},
             dataType: "json",
             success: function(data){
              $('#screen').html(data);
             }
          })
      }
    function radio(){
        $(this).addClass("selected").siblings().removeClass("selected");
        search();
        return false;
    }
    function Multiselect(){
        $(this).addClass("selected");
        search();
        return false;
    }
    function getParm(name){
      var reg = new RegExp("page=");
      var r = name.substr(1).match(reg);
      if (r != null) return unescape(r[2]); return null;
    }

</script>
<!-- selected-n-ul -->

</body>
</html>